from django.db import models
from training.users.models import Member
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
import logging

logger = logging.getLogger(__name__)

# Create your models here.
class Organization(models.Model):
    name = models.CharField(max_length = 300)
    description = models.TextField()
    teachers = models.ManyToManyField(Member, through='Membership')
    
    def __unicode__(self):
        return '%s' % self.name
    class Meta:
        verbose_name = _("organization")
        verbose_name_plural = _("organizations")
    

class Membership(models.Model):
    teacher = models.ForeignKey(Member)
    organization = models.ForeignKey(Organization)
    date_joined = models.DateField()
    
class Employee(models.Model):
    user = models.ForeignKey(User)
    organization = models.ForeignKey(Organization)
    
    class Meta:
        verbose_name = _("employee")
        verbose_name_plural = _("employees")
